package com.appengine.hotornot.service;

import javax.jdo.PersistenceManager;
import javax.servlet.http.HttpServlet;

import com.appengine.hotornot.Constants;
import com.appengine.hotornot.utils.PMF;

/**
 * Abstract service
 * @author Aliaksandr_Spichakou
 *
 */
public abstract class AbstractService extends HttpServlet implements Constants{
	/**
	 * 
	 */
	private static final long serialVersionUID = 497765818290779823L;
	private PersistenceManager persistenceManager;
	/**
	 * Get persistence manage
	 * 
	 * @return
	 */
	protected PersistenceManager getPersistenceManager() {
		if (persistenceManager == null || persistenceManager.isClosed()) {
			persistenceManager = PMF.get()
					.getPersistenceManager();
		}
		return persistenceManager;
	}
}
